package com.atguigu.guli.service.vod.controller.api;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.vod.service.MediaService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "阿里云视频点播")
 //跨域
@RestController
@RequestMapping("/api/vod/media")
@Slf4j
public class ApiMediaController {
    @Autowired
    MediaService mediaService;

    //3、根据视频id 获取未加密视频的播放地址
    @GetMapping("getPlayUrl/{vid}")
    public R getPlayUrl(@PathVariable String vid){
       String playUrl = mediaService.getPlayUrl(vid);
       return R.ok().setData("playUrl" , playUrl);
    }
    //http://localhost:8130/api/vod/media/getPlayAuth/e61cf876af5641658cae9c78bf1f6a1a
    //4、根据视频id 获取加密视频的播放凭证: 使用多
    @GetMapping("getPlayAuth/{vid}")
    public R getPlayAuth(@PathVariable String vid){
        String playAuth = mediaService.getPlayAuth(vid);
        return R.ok().setData("playAuth" , playAuth);
    }
}
